package com.example.test.a20240530;

import java.util.Scanner;

public class HJ75公共子串 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String a = in.nextLine();
        String b = in.nextLine();

        String s = a.length() > b.length() ? a : b;
        String l = a.length() > b.length() ? b : a;

        int n = 0;
        //循环短的
        for (int i = 0; i < s.length(); i++) {  //头指针递增
            for (int j = s.length() - 1; j > i; j--) {  //尾指针递减
                String temp = s.substring(i, j);
                if (l.contains(temp)) {
                    n = j - i > n ? j - i : n;  //取每次最大值
                    break;      //内循环结束
                }
            }
        }
        System.out.println("n="+n);

    }
}
